<template>
	<uni-popup ref="mealMate" type="bottom" zindex>
		<view class="mealMate-con">
			<view class="mate-title flex justify-between align-center">
				<text>请设置自动约餐</text>
				<text v-if="setDetails.startDate">{{transdTime(setDetails.startDate)}}开始</text>
			</view>
			<view class="meal-drop">
				<view class="dizhi-bg">
					<view class="textdizhi">送餐地址</view>
				</view>
				<!-- userStore.curSelecAdress -->
				<view class="dizhi-con"
					@click="mnavTo('/pages/others/addressList/addressList?source=manyMeals' + '&adressInfo=' + setedAddress.naddress_id )">
					<block v-if="setedAddress.adrs">
						<view class="flex justify-between align-center marbom">
							<text class="dzhi-font">
								{{ setedAddress.adrs }}
							</text>
							<text class="fcon-Vector mores_icons" style="margin-right: -10rpx;"></text>
						</view>
						<view class="dzhi-font99">
							<text>{{setedAddress.vname}}&nbsp;&nbsp;</text>
							<text>{{plusXing(setedAddress.vphone,3,4) }}</text>
						</view>
					</block>
					<view v-else class="flex align-center padding-bottom-xs">
						<view class="flex-sub">请选择配送地址</view>
						<text class="cuIcon-right"></text>
					</view>
				</view>
			</view>
			<view class="meal-drop">
				<view class="dizhi-bg">
					<view class="textdizhi">约餐方式</view>
				</view>
				<view class="set_meals flex  align-center flex-wrap">
					<view class="flex set_meals_li align-center flex-direction justify-center"
						v-for="(item,index) in mealsList" :class="{hoverSet : item.id == mealsClass}"
						@click="tapItemSelecMeal(item,index)" :key="index">
						<text class="meals_font" :class="{mealsfonthover:item.id == mealsClass}">{{ item.name }}</text>
						<text class="text-mels"
							:class="{textfonthover:item.id == mealsClass}">{{item.dis||item.text}}</text>
						<text class="posi-icon flex" v-if="item.id == mealsClass">
							<text class="posi-check fcon-xuanzhong"></text>
						</text>
						<!-- <text class="csico text-xxl"
	  			:class="index ==  mealsClass ? '.cuIcon-roundcheckfill' :'cuIcon-round'"></text> -->
					</view>
				</view>
			</view>
			<view class="titps-text">
				如需变更送餐时间或地址，请在送餐前2小时完成修改。
			</view>
			<view class="titps-btn flex align-center justify-center" @click="confirmSet">
				确定
			</view>
		</view>
	</uni-popup>

	<uni-popup ref="deliveryTime" type="bottom" zindex @maskClick="maskClick">
		<view class="comBotBx flex flex-direction" @click.stop="closeall">
			<view class="mtitle text-xll  prpo-w padding-lr">
				请设置配送时段
			</view>
			<view class="bg-white flex-sub dlmain nav padding-lr prpo-w margin-bottom-lg">
				<view class="flex flex-wrap">
					<view v-for="(item,index) in mealData" :key="index"
						class="cu-items p_rlt text-lg point flex flex-direction"
						:class="(index==tabClass&&item.state)||item.lselect||item.select&&item.setedTime?'act':''" @click.stop="selecyucan(item,index)"
						:data-id="index">
						<!-- <view class="rounded-bottom-triangle"></view> -->
						{{item.name}}
						<text class="margin-top-xs" v-if="item.setedTime">{{ item.setedTime}}</text>
						<view class="seleIcon">
							<view class="triangle" :class="(index==tabClass&&item.state)||item.lselect||item.select&&item.setedTime?'seleBgActive':''"></view>
							<text class="checkmark"></text>
							<!-- <text v-if="index==tabClass" class="fcon-xuanzhong"></text> -->
						</view>
						<!-- <text class="fcon-a-dsanjiao" @click.stop="selecTab(item,index)"></text> -->
						<view class="yytips flex flex-direction" v-if="item.state&&item.time">
							<scroll-view scroll-y="true" class="yyscrbx">
								<view class="yytips_li flex justify-between" v-for="(citem,cindex) in item.time"
									@click.stop="selecTips(citem,item.time,item)" :key="cindex">
									<text class="fongStyle">{{citem.text}}</text>
									<text class=" text-xll"
										:class="citem.flag?'cuIcon-roundcheckfill':'cuIcon-round'"></text>
									<!-- <text class="posi-check" :class="citem.flag ? 'fcon-xuanzhong' : ''"></text> -->
								</view>
							</scroll-view>

						</view>
					</view>
				</view>
			</view>
			<view class="padding-lr zdypadding flex justify-between flex-direction">
				<view class="zm_half bg" @click="determine">
					确定
				</view>
			</view>
		</view>
	</uni-popup>
	<!-- 自定义约餐 -->
	<setAutoMeal ref="pop1" :source="'appionted'" @confirm="sureAuto"></setAutoMeal>

</template>

<script setup lang="ts">
	import { ref, computed, onMounted } from 'vue';
	import { getMealsSec, doMealsSet, getMealsSet } from "@/api/vmeitime-http/index.js";
	import mApi from "@/utils/mapi";
	import { mnavTo, showLoading, hideLoading, plusXing, getSystemPhoneX } from '@/utils/helper';
	import { useUserStore } from '@/stores/commonStore';
	import setAutoMeal from '@/components/setAutoMeal/setAutoMeal.vue'
	const userStore = useUserStore();
	const emit = defineEmits(["confirm"])
	const props = defineProps({
		goodsId: {
			type: String,
			default: ''
		},
		fbillId: {
			type: String,
			default: ''
		},
		mealsName: {
			type: String,
			default: ''
		},
	});
	const mealMate = ref(null)
	const pop1 = ref(null)
	const switchFlag = ref(false)
	const statue = ref(null)
	const mealsClass = ref('1178') //设置自动约餐切换
	const tabClass = ref(0)//中餐晚餐
	const timeFlag = ref(false)
	const deliveryTime = ref(null)
	const lunchName = ref('')  //配送时段  午
	const dinnerName = ref('') //配送时段  晚
	const breakfastName = ref('') //配送时段  时间
	const zhong = ref('') //中
	const wan = ref('') //中
	const meal = ref('') //确定约餐时段
	const slcTimeGroup = ref<any>({});//当前选中时段7
	const slcDeliveryMode = ref<any>('');//当前选中时段
	const mealsList = ref([
		{
			name: '天天送',//1178天天送，1179工作日送,1180周末送，1181我不需要,1182自定义
			text: '每天配送',
			dis: '',
			id: '1178'
		},
		{
			name: '工作日送',
			text: '周一到周五配送',
			dis: '',
			id: '1179'
		},
		{
			name: '周末送',
			text: '周六日配送',
			dis: '',
			id: '1180'
		},
		{
			name: '手动约餐',
			text: '系统不自动约餐',
			dis: '',
			id: '1181'
		},
		{
			name: '自定义',
			text: '我时间较灵活',
			dis: '',
			id: '1182'
		}
	])

	//配送时间段
	const mealData = ref([
		// {
		// 	name: '早餐',
		// 	state: false,
		// 	setTime: '',
		// 	type: 'breakfast',
		// 	time: [
		// 		{
		// 			text: '6:30-7:00',
		// 			flag: false
		// 		},
		// 		{
		// 			text: '7:00-7:30',
		// 			flag: false
		// 		},
		// 		{
		// 			text: '7:30-8:30',
		// 			flag: false
		// 		}
		// 	]
		// },
		// {
		// 	name: '午餐',
		// 	state: false,
		// 	setTime: '',
		// 	type: 'lunch',
		// 	time: [
		// 		{
		// 			text: '11:30-12:30',
		// 			flag: true
		// 		},
		// 		{
		// 			text: '12:30-13:30',
		// 			flag: false
		// 		},
		// 		{
		// 			text: '13:00-14:00',
		// 			flag: false
		// 		}
		// 	]
		// },
		// {
		// 	name: '晚餐',
		// 	state: false,
		// 	setTime: '',
		// 	type: 'dinner',
		// 	time: [
		// 		{
		// 			text: '17:30-18:00',
		// 			flag: false
		// 		},
		// 		{
		// 			text: '18:00-19:00',
		// 			flag: false
		// 		},
		// 		{
		// 			text: '18:30-19:30',
		// 			flag: false
		// 		}
		// 	]
		// }
	])
	const setDetails = ref<any>({});//设置详情
	const setedAddress = ref<any>({});//设置地址
	const selfParams = ref<any>([]);//自定义参数
	const mealDetail = ref<any>({});
	const comMlist = ref<any>([]);//默认餐段数据
	
	// const load = () => {
	//   const firstMeal = mealData.value[0];
	//   firstMeal.setTime = firstMeal.time[0].text;
	// }

	const initData = async (source : any = '') => {
		try {
			if (!props.goodsId) {
				mApi.msg('请稍后再试');
				return
			}
			showLoading();
			// getTimeSec();
			let res = await getMealsSet({ goodsId: props.goodsId || '', fatherBillId: props.fbillId })
			if (!res.result || !res.object) {
				hideLoading();
				mApi.msg(res.shortMessage || '网络繁忙，请稍后.', res.code)
				// return
			}
			let nres = res.object || {};
			setDetails.value = nres;
			let cres = await getMealsSec({ goodsId: props.goodsId });
			let comRlist : any = [];
			if (cres.result && cres.object) {
				comRlist = initCanDuan(cres.object || []);
				comMlist.value = comRlist;
				console.log('getTimeSec+',mealData.value)
			} else {
				mApi.msg(cres.shortMessage || '网络繁忙，稍后再试', cres.code)
			}
			let tAddress = nres.tradeAddress || {}, slcGroup : any = {};// {'1178':{1187:'11:30-12:30'}}
			tAddress.adrs = (tAddress.vprovince || '') + (tAddress.vcity || '') + (tAddress.vcounty || '') + (tAddress.vaddre_detail || '');
			tAddress.source = 'manyMeals';
			setedAddress.value = tAddress;
			slcDeliveryMode.value = nres.deliveryMode || '';
			// slcGroup[nres.deliveryMode] = {};//new777
			mealsClass.value = nres.deliveryMode || '';//天天送、工作日送等
			console.log('mealsClass-01', mealsClass.value)
			if (nres.diyTime&&nres.diyTime.length>0&&nres.deliveryMode&&nres.deliveryMode!='1181'&&nres.deliveryMode!='1182') {
				
				// let rtyarr = nres.rangeType.split(',');
				// let rtmarr = nres.rangeTime.split(',');
				for (let i = 0; i < nres.diyTime.length; i++) {
					// let item = rtyarr[i];
					// !slcGroup[item] ? slcGroup[item] = rtmarr[i] : '';
					let key = nres.diyTime[i].rangeType;
					!slcGroup[key] ? slcGroup[key] = nres.diyTime[i] : '';
					// !slcGroup[nres.deliveryMode][item] ? slcGroup[nres.deliveryMode][item] = rtmarr[i] : '';//new777
					// !slcGroup[item]?slcGroup[item]=[{id:item,rangeTime:rtmarr[i]}]:slcGroup[item].push({id:item,rangeTime:rtmarr[i]})
				}
				
				// 初始化早中晚配置时间
				// mealData.value.forEach(item => {
				// 	if(slcGroup[item.id]){
				// 		item.setedTime = slcGroup[item.id];
				// 		curDis += curDis ? '/' + item.name : item.name
				// 	}
				// 	// if (ngoup[item.id]) {
				// 	// 	let cindex = item.time.findIndex(citem => citem.text == ngoup[item.id])
				// 	// 	cindex >= 0 ? item.time[cindex].flag = true : '';
				// 	// 	cindex >= 0 ? item.setedTime = ngoup[item.id] : '';
				// 	// }
				// 	// if(item.setedTime){
				// 	// 	curDis += curDis ? '/' + item.name : item.name
				// 	// }
				// 	console.log('curDis',curDis,item.setedTime)
				// 	// curDis += item.setedTime ? (curDis ? '/' + item.name : item.name) : '';
				// })
				
				//默认展示
				// mealsList.value.forEach((mitem : any) => {
				// 	let rangeList = JSON.parse(JSON.stringify(comRlist));
				// 	if (mitem.id && mitem.id == nres.deliveryMode) {
				// 		rangeList.forEach(ritem => {
				// 			ritem.lselect = false;
				// 			if (slcGroup[ritem.id]) {
				// 				ritem.select = true;
				// 				ritem.setedTime = slcGroup[ritem.id].rangeTime;
				// 				curDis += curDis ? '/' + ritem.name : ritem.name;
				// 				let ctimes = ritem.time || [];
				// 				ctimes.forEach(titem => {
				// 					titem.flag = titem.text == slcGroup[ritem.id].rangeTime ? true : false;
				// 				})
				// 			}else{
				// 				ritem.select = false;
				// 			}

				// 		})
				// 		mealData.value = rangeList;
				// 		mitem.dis = curDis
				// 	}
				// 	mitem.rangeList = rangeList;
				// 	// mitem.id && mealsClass.value == mitem.id ? mitem.dis = curDis : '';
				// 	// mitem.dis = mitem.id&&mealsClass.value==mitem.id?curDis:'';
				// })
				// let mindex = mealsList.value.findIndex(mitem=>mitem.id==mealsClass.value)
				// slcTimeGroup.value = slcGroup;
				
			}
			//默认展示
			let curDis = '';//ngoup = slcGroup[nres.deliveryMode] || {},
			mealsList.value.forEach((mitem : any) => {
				let rangeList = JSON.parse(JSON.stringify(comRlist));
				if (mitem.id && mitem.id == nres.deliveryMode) {
					rangeList.forEach(ritem => {
						ritem.lselect = false;
						if (slcGroup[ritem.id]) {
							ritem.select = true;
							ritem.setedTime = slcGroup[ritem.id].rangeTime;
							curDis += curDis ? '/' + ritem.name : ritem.name;
							let ctimes = ritem.time || [];
							ctimes.forEach(titem => {
								titem.flag = titem.text == slcGroup[ritem.id].rangeTime ? true : false;
							})
						}else{
							ritem.select = false;
						}
			
					})
					mealData.value = rangeList;
					mitem.dis = curDis
				}
				mitem.rangeList = rangeList;
				// mitem.id && mealsClass.value == mitem.id ? mitem.dis = curDis : '';
				// mitem.dis = mitem.id&&mealsClass.value==mitem.id?curDis:'';
			})
			// 自定义约餐默认数据
			if(nres.diyTime&&nres.diyTime.length>0&&nres.deliveryMode=='1182'){
				let sfl:any=[];
				nres.diyTime.forEach(ditem=>{
					ditem.rangeType&&sfl.push({rangeType:ditem.rangeType,rangeTime:ditem.rangeTime,seq:ditem.seq})
				})
				selfParams.value = sfl;
			}
			console.log('slcGroup01', slcGroup, curDis);
			console.log('mealData', mealData.value);
			console.log('mealsList-end', mealsList.value);
			hideLoading();
			// mealMate.value.open()
			showPop('mealMate');

		} catch (e) {
			console.error(e)
		}
	}
	// 获取餐段时间列表
	const getTimeSec = async () => {
		try {
			let res = await getMealsSec({ goodsId: props.goodsId })
			if (res.result && res.object) {
				mealData.value = initCanDuan(res.object || []);
				console.log('getTimeSec', mealData.value)
			} else {
				mApi.msg(res.shortMessage || '网络繁忙，稍后再试', res.code)
			}
		} catch (e) {
			console.error(e)
		}

	}
	const initCanDuan = (list : any = []) => {
		if (list.length > 0) {
			// let rp = setDetails.value.rangeType||'',rt = setDetails.value.rangeTime||'';
			// rp = rp.split(',');
			// rt = rt.split(',');
			list.forEach(item => {
				let index = item.time ? item.time.findIndex(citem => citem.flag) : -1;
				console.log('initCanDuan00', index)
				item.state = false;
				item.id = item.rangeType;
				item.setedTime = index >= 0 ? item.time[index].text : '';
				item.name = item.id == '1186' ? '早餐' : item.id == '1187' ? '午餐' : item.id == '1188' ? '晚餐' : '';
			})
		}
		console.log('initCanDuan', list)
		return list
	}
	// 手动选择地址更新
	const upAdress = () => {
		if (uni.getStorageSync('mealsAdresTips')) {
			setedAddress.value = userStore.curSelecAdress;
			uni.setStorageSync('mealsAdresTips', false);
		}
	}
	const open = () => {
		initData('open')
	}

	const close = () => {
		// mealMate.value.close()
		hidePop('mealMate')
	}

	// const tapSure = () => {
	// 	emit("confirm", { statue: switchFlag.value })
	// 	close()
	// }

	// const changeSwitch = (e) => {
	// 	switchFlag.value = e.detail
	// 	console.log(e.detail, '---------------------', switchFlag.value)
	// }

	//选泽约餐中 或晚
	const selecyucan = (item : any, index : any) => {
		item.lselect = item.setedTime?true:false;
		tabClass.value = index;
		mealData.value.forEach((i : any) => {
			i.state = i === item ? !i.state : false; // 仅切换当前项的状态，其它项关闭
		})
	}

	//选泽具体约餐时间区段
	const selecTips = (list : any, data : any, fatherItem : any) => {
		// fatherItem.setTime = list.text
		if (list.flag) {
			list.flag = false
			fatherItem.setedTime = "";
			fatherItem.lselect = false;
		} else {
			data.forEach((item : any) => {
				item.flag = false
			})
			list.flag = true
			fatherItem.setedTime = list.text; // 赋值为当前选中项的文本
			fatherItem.lselect = true;
		}
		setTimeout(() => {
			mealData.value.forEach((i : any) => {
				i.state = false;
			});
		}, 60);
	}
	//确定约餐时间 回调约餐时间
	const determine = () => {
		let curDis = '', cgroup : any = {}, slcGroup : any = slcTimeGroup.value;	
		let mindex = mealsList.value.findIndex(mitem => mitem.id == mealsClass.value)
		let hasSlc = mealData.value.some(mitem=>mitem.lselect)
		if(hasSlc){
			mealsList.value.forEach((fitem:any,index:any) => {
				console.log('dddddsdfa',fitem)
				fitem.rangeList.forEach(item => {
					item.select = false;
					// mindex>=0&&mindex==index&&item.setedTime&&item.lselect?curDis = curDis + (curDis ? '/' + item.name : item.name):item.select = false;
					if(mindex>=0&&mindex==index&&item.setedTime&&item.lselect){
						item.select = true;
						curDis = curDis + (curDis ? '/' + item.name : item.name)
					}
				})
				mindex>=0&&mindex==index?fitem.dis = curDis:'';
			})
		}	
		// 确认选择
		// mealData.value.forEach(item => {
		// 	item.setedTime ? curDis = curDis + (curDis ? '/' + item.name : item.name) : '';
		// 	// item.time.forEach(citem=>{
		// 	// 	if(citem.flag){
		// 	// 		!cgroup[item.id]?cgroup[item.id] = citem.text:''
		// 	// 	}
		// 	// })		
		// });
		// console.log('mealsList+',mealsList)
		console.log('mealData+1', mealData.value)
		// slcDeliveryMode.value = mealsClass.value;
		// let mindex = mealsList.value.findIndex(mitem => mitem.id == mealsClass.value)
		// mindex >= 0 ? mealsList.value[mindex].dis = curDis : '';
		// slcGroup[mealsClass.value] = cgroup;
		// slcTimeGroup.value = slcGroup;//暂存数据
		console.log('determine', mealsList.value);
		hidePop('deliveryTime')
		// deliveryTime.value.close()
	}
	const closeall = () => {
		mealData.value.forEach((item : any) => {
			item.state = false
		})
	}
	// 约餐方式-点击
	const tapItemSelecMeal = (item : any, index : any) => {
		mealsClass.value = item.id;
		// slcDeliveryMode
		if (item.id == '1182') {
			showPop('pop1') //设置自定义约餐
			// updateMealText(item.id)
		} else if (item.id == '1181') {
			//不需自动约餐
			// updateMealText(item.id)
		} else {
			// let group:any ={};
			// group = slcTimeGroup.value[mealsClass.value]||{};
			// console.log('tapItemSelecMeal',slcTimeGroup.value)
			mealData.value = item.rangeList || comMlist.value||[];
			mealData.value.forEach(fitem=>{
				fitem.lselect = false;
				// // 同步暂存数据
				// // console.log('slcDeliveryMode',slcDeliveryMode.value&&slcDeliveryMode.value==mealsClass.value,slcTimeGroup.value[fitem.id])
				// // fitem.setedTime = slcDeliveryMode.value&&slcDeliveryMode.value==mealsClass.value&&slcTimeGroup.value[fitem.id]?slcTimeGroup.value[fitem.id]:'';
				// fitem.setedTime = group&&group[fitem.id]?group[fitem.id]:'';
				// fitem.time.forEach(citem=>{
				// 	citem.flag = group&&group[fitem.id]&&group[fitem.id]==citem.text?true:false;
				// })
			})
			tabClass.value = null;
			showPop('deliveryTime')
		}
	}
	// 设置约餐提交
	const confirmSet = async () => {
		let ndata : any = {
			goodsId: props.goodsId || '',
			goodsName: props.mealsName || '',
			startDate: '',
			meal_cycle_type: '1192',//约餐时间模式(1191：日，1192：周)
			deliveryMode: mealsClass.value || '',//配送模式（天天送、工作日送、节假日送、自定义，我不需要）
			father_bill_id: props.fbillId || '',
			consignee: setedAddress.value.vname || '',//userStore.curSelecAdress
			phone: setedAddress.value.vphone || '',
			address_id: setedAddress.value.naddress_id || '',
			address_detail: setedAddress.value.adrs || '',
			// diyTime:'',//自定义时间（如果是自定义则必传）
			// timeRangeType:'',//非自定义时间（如果不是自定义则必传）

		};
		if (!ndata.address_id) {
			mApi.msg('请选择配送地址')
			return
		}
		if (mealsClass.value != '1182' && mealsClass.value != '1181') {
			let rty = [], rtm = [];
			mealData.value.forEach(item => {
				if (item.setedTime) {
					rty.push(item.id);
					rtm.push(item.setedTime);
				}
			})
			ndata.rangeType = rty.join(',');
			ndata.rangeTime = rtm.join(',');
		}
		// mealsClass.value != '1182' ? ndata.rangeType = '1188,1187' : '';
		// mealsClass.value != '1182' ? ndata.rangeTime = '11:30-12:30,11:30-12:30' : '';

		if (mealsClass.value == '1182') {
			// let diyTime : any = [];
			// for (let i = 0; i < 1; i++) {
			// 	diyTime.push({
			// 		preTime: '20241031',
			// 		rangeType: '1188',
			// 		rangeTime:'11:30-12:30'
			// 	})
			// }
			ndata.diyTime = selfParams.value;
		}
		try {
			showLoading();
			let res = await doMealsSet(ndata);
			hideLoading();
			pop1.value.rezData();
			hidePop('mealMate')
		} catch (e) {
			hideLoading();
			console.error(e)
		}

	}
	// 自动约餐确认
	const sureAuto = (param : any) => {
		selfParams.value = param.list;
		console.log('自动约餐确认', selfParams.value)
	}
	//配送时段遮罩层触发
	const maskClick = (e) => {
		closeall();
		// updateMealText(mealsClass.value)
	}

	//配送时段文案重置
	// const updateMealText = (targetId : any) => {
	// 	mealsList.value.forEach(item => {
	// 		if (item.id === targetId) {
	// 			item.text = "";
	// 		} else {
	// 			// 恢复其他项的原有值 1178天天送，1179工作日送,1180周末送，1181我不需要,1182自定义
	// 			switch (item.id) {
	// 				case '1178':
	// 					item.text = '每天配送';
	// 					break;
	// 				case '1179':
	// 					item.text = '周一到周五配送';
	// 					break;
	// 				case '1180':
	// 					item.text = '周六日配送';
	// 					break;
	// 				case '1181':
	// 					item.text = '系统不自动约餐';
	// 					break;
	// 				case '1182':
	// 					item.text = '我时间较灵活';
	// 					break;
	// 				default:
	// 					item.text = ''; // 其他情况可根据需求处理
	// 			}
	// 		}
	// 	});
	// };

	const showPop = (source : string, item : any = {}) => {
		console.log('showPop', item)
		switch (source) {
			case 'mealMate':
				mealMate.value?.open()
				break;
			case 'pop1':
				pop1.value?.open(props.goodsId, props.fbillId)
				break;
			case 'deliveryTime':
				deliveryTime.value?.open()
				break;
			default:
				break;
		}
	}
	const hidePop = (source : string) => {
		switch (source) {
			case 'mealMate':
				mealMate.value?.close()
				break;
			case 'pop1':
				pop1.value?.close()
				break;
			case 'deliveryTime':
				deliveryTime.value?.close()
				break;
			default: deliveryTime
				break;
		}
	}
	const transdTime = (v) => {
		let r = '';
		if (v) {
			r = v.substring(0, 4) + '-' + v.substring(4, 6) + '-' + v.substring(6, 8);
		}
		return r

	}

	defineExpose({ open, close, upAdress })
</script>

<style scoped lang="scss">
	// 设置自动约餐弹窗
	.mealMate-con {
		min-height: 1010rpx;
		max-height: 96vh;
		border-radius: 20rpx 20rpx 0 0;
		background: #F3F3F3;
		padding: 0 26rpx 40rpx 26rpx;

		.titps-text {
			color: #999;
			font-size: 28rpx;
			margin: 20rpx auto;
			font-style: normal;
			font-weight: 400;
		}

		.titps-btn {
			width: 704.66rpx;
			height: 88rpx;
			color: #FFF;
			font-size: 32rpx;
			font-weight: 400;
			border-radius: 38rpx;
			background: #53A87F;
		}

		.meal-drop {
			border-radius: 20rpx;
			background: #FFF;
			box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.10);
			margin-bottom: 34rpx;

			.set_meals {
				padding: 0rpx 25rpx 30rpx 25rpx;

				.set_meals_li {
					width: 204rpx;
					height: 124rpx;
					flex-shrink: 0;
					background: #fff;
					border-radius: 10rpx;
					box-shadow: 0px 4px 40px 0px rgba(0, 0, 0, 0.08);
					padding: 0rpx 17rpx;
					margin-right: 19rpx;
					margin-bottom: 30rpx;
					border: 1px solid #fff;
					box-sizing: border-box;
					position: relative;
				}

				.posi-icon {
					position: absolute;
					bottom: 0;
					right: -1px;
					border-radius: 10rpx 0px;
					border: 1px solid #53A87F;
					background: #53A87F;
					width: 30.363rpx;
					height: 26.254rpx;
					padding-left: 5rpx;

					.posi-check {
						display: block;
						margin-top: 5rpx;
						font-size: 15rpx;
						color: #fff;
					}
				}

				.meals_font {
					color: #333;
					font-size: 32rpx !important;
					font-weight: 400;
				}

				.mealsfonthover {
					color: #53A87F !important;
					font-weight: 700 !important;
				}

				.textfonthover {
					color: #53A87F !important;
				}

				.text-mels {
					color: rgba(153, 153, 153, 0.70);
					font-size: 24rpx;
					font-weight: 400;
					margin-top: 8rpx;
				}

				.set_meals_li:nth-child(3n) {
					margin-right: 0rpx;
				}

				.hoverSet {
					background-image: url('https://cdn-static.yekjx.com/food/ico/images/crod_bg01.png');
					background-size: cover;
					background-repeat: no-repeat;
					border: 1px solid #53A87F !important;
				}

				.meals_font {
					color: #333;
					font-family: "Microsoft YaHei UI";
					font-size: 30rpx;
					font-weight: 400;
				}

				.csico {
					margin-left: 10rpx;
				}
			}

			.dizhi-bg {
				padding: 14rpx 0 0 20rpx;
				height: 102rpx;
				border-radius: 20rpx 20rpx 0 0;
				background: linear-gradient(180deg, #E4FEEE 50%, #FFF 93.61%);
				color: #333;
				font-size: 32rpx;
				font-weight: 400;

				.textdizhi {
					position: relative;
					padding-left: 30rpx;

					&:before {
						content: '';
						width: 6rpx;
						height: 80%;
						background-color: #53A87F;
						position: absolute;
						left: 0;
						top: 50%;
						transform: translateY(-50%);
					}
				}
			}

			.dizhi-con {
				padding: 0 26rpx 20rpx 20rpx;

				.dzhi-font {
					color: #333;
					font-size: 32rpx;
					font-weight: 400;
				}

				.dzhi-font99 {
					color: #999;
					font-size: 28rpx;
					font-weight: 400;
				}

				.marbom {
					margin-bottom: 10rpx;
				}
			}
		}

		.mate-title {
			height: 134rpx;

			text {
				&:last-child {
					color: #999;
					font-size: 32rpx;
					font-weight: 400;
				}

				&:first-child {
					color: #333;
					font-size: 40rpx;
					font-weight: 700;
				}
			}
		}
	}

	.comBotBx {
		min-height: 702rpx;
		max-height: 96vh;
		background-color: #fff !important;

		.nav .cu-items.curHover {
			position: relative;
		}

		.nav .cu-items {
			width: 329rpx;
			height: 130rpx;
			padding-left: 36rpx;
			padding-top: 20rpx;
			// border-bottom: 4rpx solid #F5F5F5;
			position: relative;
			border-radius: 5px;
			background: #F7F7F7;
			margin-right: 34rpx;
			margin-bottom: 30rpx;
			position: relative;

			&:nth-child(2n) {
				margin-right: 0;
			}
		}

		.nav .cu-items.curHover {
			// border-bottom: 6rpx solid;
			position: relative;
		}

		.seleIcon {
			width: 36rpx;
			height: 36rpx;
			position: absolute;
			right: 5rpx;
			bottom: 5rpx;

			.seleBgActive {
				border-bottom: 30rpx solid #53A87F !important;
			}

			.triangle {
				width: 0;
				height: 0;
				border-left: 30rpx solid transparent;
				border-bottom: 30rpx solid #D3D3D3;
				position: absolute;
			}

			.checkmark {
				position: absolute;
				top: 8rpx;
				left: 14rpx;
				width: 12rpx;
				height: 24rpx;
				border: solid #fff;
				border-width: 0 4rpx 4rpx 0;
				transform: rotate(45deg) scale(0.6);
			}

			.color33 {
				color: #333;
			}

			.fcon-xuanzhong {
				color: #fff;
				position: absolute;
				right: 10rpx;
				top: -8rpx;
				transform: rotate(-5deg);

				&:before {
					font-size: 9rpx !important;
				}
			}
		}

		.mtitle {
			color: #333;
			font-size: 40rpx;
			font-weight: 700;
			padding: 32rpx 30rpx;
		}

		// .marbittom {
		// 	margin-bottom: 40rpx;
		// }
		.dlmain{
			min-height: 450rpx;
			max-height: 64vh;
		}

		.yyscrbx {
			width: 100%;
			height: 324rpx;
		}

		.yytips {
			position: absolute;
			width: 100%;
			height: 324;
			flex-shrink: 0;
			z-index: 999;
			bottom: -345rpx;
			left: 0rpx;
			background-color: #fff;
			border-radius: 20rpx;
			box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1);

			.yytips_li {
				border-bottom: 1px solid #f2f2f2;
				padding: 0 20rpx;
				height: 106rpx;
				align-items: center;

				.fongStyle {
					color: #333;
					font-family: "Microsoft YaHei UI";
					font-size: 16px;
					font-style: normal;
					font-weight: 400;
					line-height: normal;
				}
			}

			.yytips_li:last-child {
				border-bottom: none;
			}
		}

		.cuIcon-round {
			color: #999;
		}

		.cuIcon-roundcheckfill {
			color: $base-color;
		}

		.zdypadding {
			padding-top: 20rpx;
			padding-bottom: 40rpx;
		}

		.zm_half {
			width: 704.664rpx;
			font-size: 32rpx;
			text-align: center;
			height: 88rpx;
			line-height: 89rpx;
			// box-shadow: 0px 10px 40px rgba(76, 162, 123, 0.26);
			border-radius: 16rpx;
			cursor: pointer;
			background: #fff;
			color: #999;
			border: 1px solid #999;
			// margin-top: 350rpx;

			&.bg {
				color: #fff;
				background: $view-act;
			}
		}
	}
</style>